<%@page import="dao.QuizAnswersDao"%>
<%@page import="models.Quiz"%>
<%@page import="dao.QuizDao"%>
<%@page import="classes.Valuta"%>
<%@page import="models.User"%>
<%@include file="template/configuration.jsp" %>
<%@page import="java.util.List"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>${website} || Manage Questions</title>
        ${stylesheet}
        ${jquery}
        ${jstooltip}
        ${jscollapse}
    </head>
    <body>
        <div class="container">
            <%@include file="template/header.jsp" %>
            <div class="content">
                <h1>Manage questions</h1>
                <!-- clear //-->
                <div class="clear margin-bottom-10"></div>
                            <div class="bundle">
                                <div class="top">
                                    <div class="left">
                                    </div>
                                    <div class="center">
                                        <h5>${quiz.name}</h5>
                                    </div>
                                    <div class="right">
                                            <a href="ManageQuizQuestion?quizid=${quiz.id}">Add a new question<img src="${url}images/add.png" /></a>
                                    </div>
                                </div>
                                <!-- clear //-->
                                <div class="clear"></div>
                                <div class="full-block">    
                                <c:choose>
                                    <c:when test="${fn:length(questions)!=0}">
                                        <div>
                                            <table class="overview">
                                                <tr>
                                                    <th class="manage">Number</th>
                                                    <th>Question</th>
                                                    <th>Explanation</th>
                                                    <th class="manage">Manage</th>
                                                </tr>
                                                <%
                                                HibernateUtil huti = new HibernateUtil();
                                                QuizAnswersDao qadao = new QuizAnswersDao(huti.openSession());
                                                %>
                                                <c:set var="i" value="0"/>
                                                <c:forEach items="${questions}" var="question" varStatus="counter">
                                                    <c:set var="i" value="${i + 1}"/>
                                                    <tr class="<c:choose><c:when test="${i % 2 == 0}">even</c:when><c:otherwise>odd</c:otherwise></c:choose>">
                                                        <td>${question.order}</td>
                                                        <td>
                                                            ${question.name}
                                                        </td>
                                                        <td>
                                                            ${question.explanation}
                                                        </td>
                                                        <td>
                                                            <a href="ManageQuizQuestion?idedit=${question.id}"><img src="${url}images/edit.png" /></a> 
                                                                <a href="ManageQuizQuestion?idremove=${question.id}" class="remove"><img src="${url}images/remove.png" /></a>
                                                                <span class="info">question <strong>${question.name}</strong></span>
                                                        </td> 
                                                    </tr>
                                                </c:forEach>
                                            </table>
                                        </div>
                                    </c:when>
                                    <c:otherwise>
                                        <div class="no-yet-message">
                                            There are no questions in this quiz yet.
                                        </div>
                                    </c:otherwise>
                                </c:choose>
                                </div>
                                <!-- clear //-->
                                <div class="clear margin-bottom-10"></div>
                            </div>
            </div>
            <%@include file="template/footer.jsp" %>
        </div>
    </body>
</html>
